package com.git.hui.yinshua.api.model;

import lombok.Data;

import java.io.Serializable;
import java.util.List;


/**
 * @author YiHui
 * @date 2024/6/7
 */
@Data
public class ListRsp<T> implements Serializable {
    private static final long serialVersionUID = 7636641215017865091L;
    /**
     * 列表
     */
    private List<T> list;

    /**
     * 下一页序号
     */
    private Integer next;

    /**
     * 是否为最后一页
     */
    private Boolean end;

    /**
     * 总数
     */
    private Integer total;

    public static <T> ListRsp<T> newRsp(List<T> list, Integer page, Integer size) {
        ListRsp<T> rsp = new ListRsp<>();
        rsp.list = list;
        rsp.next = page + 1;
        rsp.end = list.size() < size;
        return rsp;
    }
}
